package com.sunwayhorizo.health.platform.security.persistent;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.TableGenerator;

import com.sunwayhorizo.health.platform.util.BeanHelper;

@Entity
@TableGenerator(name = "SecurityPermissionRole_IdGenerator", table = "ET_Id_Generator", pkColumnName = "pkColumn", valueColumnName = "valueColumn", pkColumnValue = "SECURITY_PERMISSION_ROLE_ID",allocationSize=50)
@Table(name = "SECURITY_PERMISSION_ROLE", schema = "ETS")
public class SecurityPermissionRole implements java.io.Serializable {
	
	@Id
	@GeneratedValue(strategy = GenerationType.TABLE, generator = "SecurityPermissionRole_IdGenerator")
	@Column(name = "PERMISSION_ROLE_ID", unique = true, nullable = false, length = 32)
	private String permissionRoleId;
	
	@ManyToOne
	@JoinColumn(name = "ROLE_ID")
	private SecurityRole role;
	
	@ManyToOne
	@JoinColumn(name = "PERMISSION_ID")
	private SecurityPermission permission;

	public SecurityPermissionRole() {
	}

	public SecurityPermissionRole(String permissionRoleId,
			SecurityRole role, SecurityPermission permission) {
		this.permissionRoleId = permissionRoleId;
		this.role = role;
		this.permission = permission;
	}

	
	public String getPermissionRoleId() {
		return this.permissionRoleId;
	}

	public SecurityPermissionRole(String permissionRoleId, SecurityRole role)
    {
        super();
        this.permissionRoleId = permissionRoleId;
        this.role = role;
    }

    public void setPermissionRoleId(String permissionRoleId) {
		this.permissionRoleId = permissionRoleId;
	}

	public SecurityRole getRole() {
		return this.role;
	}

	public void setRole(SecurityRole role) {
		this.role = role;
	}

	public SecurityPermission getPermission() {
		return this.permission;
	}

	public void setPermission(SecurityPermission permission) {
		this.permission = permission;
	}
	
	@Override
	public String toString() {
		return BeanHelper.toString(this);
	}
}
